package com.hzit.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzit.dto.StudentDTO;
import com.hzit.entity.Student;
import com.hzit.mapper.StudentMapper;
import com.hzit.service.IStudentService;
import com.hzit.util.Conver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements IStudentService {
	@Autowired
	private Conver conver;
	//1. 查询所有学生
	@Override
	public List<StudentDTO> findAll() {
		return conver.entity2DTO(this.list());
	}

	@Override
	public void add(StudentDTO dto) {
		Student student = conver.dto2Entity(dto);
		this.save(student);
	}

	@Override
	public void update(StudentDTO dto) {
		Student student = conver.dto2Entity(dto);
		this.updateById(student);
	}
}
